import React, { useEffect, useState } from 'react'
import { Form, Select } from 'antd'
import { $get } from '@src/assets/js/authRequest'
import { awaitWrap } from '@src/assets/js/tool'
const { Item } = Form

async function getListRequest () {
  const res = await $get('/api/mgt/institutionstat', {
    condition: JSON.stringify([{ k: 'pid', o: 'null' }])
  })
  return res.data
}

async function initList (setOptions) {
  const [e, d] = await awaitWrap(getListRequest())
  if (e === null && d !== null) {
    setOptions(d.map(li => ({ label: li.name, value: li.tenant_code })))
  }
}

function Main () {
  const [options, setOptions] = useState([])
  useEffect(() => {
    initList(setOptions)
  }, [])
  return (
    <Item label='仲裁机构' name='tenant_code'>
      <Select placeholder='请选择' options={options} optionFilterProp='label' showSearch allowClear />
    </Item>
  )
}

export default Main
